﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;

namespace WatiN.Sharepoint.Pages
{
    public abstract class BaseCentralAdminPage : BaseSPPage 
    {
        public string CentralAdminRootUrl { get; private set; }

        public BaseCentralAdminPage()
            : base()
        {
            CentralAdminRootUrl = Settings.CentralAdminRootUrl;
        }

        public abstract string RelativePageUrl
        {
            get;
        }

        public virtual void GoTo(Browser browser)
        {
            GoTo(browser, RelativePageUrl, null);
        }

        public virtual void GoTo(Browser browser, Dictionary<string, string> parameters)
        {
            GoTo(browser, RelativePageUrl, parameters);
        }

        public override void GoTo(Browser browser, string pageUrl, Dictionary<string, string> parameters) 
        {
            string url = string.Format("{0}/{1}", Settings.CentralAdminRootUrl.TrimEnd('/'), pageUrl.TrimStart('/'));

            base.GoTo(browser, url, parameters);
        }
    }
}
